import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { Component } from 'vue';

declare type Lazy<T> = () => Promise<T>;
declare type RawRouteComponent = Component | Lazy<Component>;

const BasicLayout: RawRouteComponent = () => import('/@/layouts/BasicLayout.vue');

console.log(BasicLayout)

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    meta: { hidden: true },
    component: BasicLayout,
    children: [
      { path: '/', redirect: '/home', meta: { hidden: true }, },
      {
        path: '/home',
        meta: { requiresAuth: true, keepAlive: false, name: 'home', title: '首页', hidden: true },
        component: () => import(/* @vite-ignore */'/@/views/home/index.vue'),
      },
      {
        path: '/posts',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: true, name: 'posts', title: '帖子', },
        component: () => import(/* @vite-ignore */'/@/views/posts/index.vue'),
        children: [
          {
            path: 'profile',
            meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: true, name: 'profile', title: '个人', },
            component: () => import(/* @vite-ignore */'/@/views/posts/profile.vue'),
            children: [
              {
                path: 'profile',
                meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: true, name: 'profile', title: '资料', },
                component: () => import(/* @vite-ignore */'/@/views/posts/profile.vue'),
              }
            ]
          }
        ]
      },
      {
        path: '/archive',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'archive', title: '档案', },
        component: () => import(/* @vite-ignore */'/@/views/archive/index.vue'),
      },
      {
        path: '/about',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'about', title: '关于我们', },
        component: () => import(/* @vite-ignore */'/@/views/about/index.vue'),
      },
      {
        path: '/goods',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'goods', title: '商城', },
        component: () => import(/* @vite-ignore */'/@/views/goods/index.vue'),
      },
      {
        path: '/join',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'join', title: '加入', },
        component: () => import(/* @vite-ignore */'/@/views/join/index.vue'),
      },
      {
        path: '/list',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'list', title: '产品列表', },
        component: () => import(/* @vite-ignore */'/@/views/list/index.vue'),

      },
      {
        path: '/wind',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'wind', title: '风采', },
        component: () => import(/* @vite-ignore */'/@/views/wind/index.vue'),
      },
      {
        path: '/position',
        meta: { icon: 'el-icon-platform-eleme', requiresAuth: true, keepAlive: false, name: 'position', title: '导航', },
        component: () => import(/* @vite-ignore */'/@/views/position/index.vue'),
      },
    ],
  },
];

console.log(routes)

const router = createRouter({
  // 4. Provide the history implementation to use. We are using the hash history for simplicity here.
  history: createWebHashHistory(),
  routes, // short for `routes: routes`
})

export default router;